# PowerShell脚本执行SQL
Write-Host "正在创建数据库..." -ForegroundColor Green

# 尝试使用MySQL客户端执行SQL
try {
    # 检查mysql命令是否可用
    $null = & mysql --version 2>$null
    if ($LASTEXITCODE -eq 0) {
        Write-Host "找到MySQL客户端，开始执行SQL..." -ForegroundColor Yellow
        Get-Content "create_database.sql" | & mysql -h localhost -P 3306 -u root -p123456
        if ($LASTEXITCODE -eq 0) {
            Write-Host "数据库创建成功！" -ForegroundColor Green
        } else {
            Write-Host "SQL执行失败，错误代码: $LASTEXITCODE" -ForegroundColor Red
        }
    } else {
        Write-Host "未找到MySQL客户端" -ForegroundColor Red
    }
} catch {
    Write-Host "执行过程中发生错误: $($_.Exception.Message)" -ForegroundColor Red
}

Write-Host "按任意键继续..." -ForegroundColor Yellow
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
